import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/tm/resume/list',
  lockList = '/tm/resume/lock/list',
  save='/tm/resume/add',
  edit='/tm/resume/edit',
  deleteOne = '/tm/resume/delete',
  deleteBatch = '/tm/resume/deleteBatch',
  importExcel = '/tm/resume/importExcel',
  exportXls = '/tm/resume/exportXls',
  queryDataById = '/tm/resume/queryById',
  resumeEvaluateRecordList = '/tm/resume/queryResumeEvaluateRecordByMainId',
  projectEntryDetailList = '/tm/resume/queryProjectEntryDetailByMainId',
  departureEvaluateRecordList = '/tm/resume/queryDepartureEvaluateRecordByMainId',
  lockPositionReqRecordList = '/tm/resume/queryLockPositionReqRecordListByMainId',
  resumeFilterUrl='/tm/resume/filter',
  operatorFilterUrl = '/tm/resume/operator/filter',
  
}


/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;

/**
 * 查询锁定需求表数据
 * @param params
 */
export const queryLockPositionReqRecordListByMainId = (id) => defHttp.get({url: Api.lockPositionReqRecordList, params:{ id }});

/**
 * 查询子表数据
 * @param params
 */
export const queryResumeEvaluateRecordListByMainId = (id) => defHttp.get({url: Api.resumeEvaluateRecordList, params:{ id }});
/**
 * 查询子表数据
 * @param params
 */
export const queryProjectEntryDetailListByMainId = (id) => defHttp.get({url: Api.projectEntryDetailList, params:{ id }});
/**
 * 查询子表数据
 * @param params
 */
export const queryDepartureEvaluateRecordListByMainId = (id) => defHttp.get({url: Api.departureEvaluateRecordList, params:{ id }});

/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});


export const lockList = (params) =>
defHttp.get({url: Api.lockList, params});
  

export const lockPositionReqRecordList = (params) =>
defHttp.get({url: Api.lockList, params});
/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}

/**
 * 简历筛选
 * @param params
 */
export const opertResumeFilter = (params) => {
  return defHttp.post({url: Api.resumeFilterUrl, params});
}

/**
 * 简历筛选
 * @param params
 */
export const operatorFilter = (params) => defHttp.post({url: Api.operatorFilterUrl, params});
/**
* 根据id查询数据
* @param params
*/
export const queryDataById = (id) => defHttp.get({url: Api.queryDataById, params:{ id }});






